#include <cjsonname.h>
#include <cjsonerror.h>

CJsonName::CJsonName(jstring & name)
{
#ifdef CJSON_NULL_NAMES_RESTRICTED
  if (name.empty())
  {
    throw CJsonError(INVALID_PARAM);
  }
#endif
  this->name = name;
}

CJsonName::CJsonName(const jchar *name)
{
  if (!name)
  {
    throw CJsonError(INVALID_PARAM);
  }
#ifdef CJSON_NULL_NAMES_RESTRICTED
  if (*name == J('\0'))
  {
    throw CJsonError(INVALID_PARAM);
  }
#endif
  jstring temp(name);
  this->name = temp;
}

jstring CJsonName::ToString()
{
  return J("\"") + name + J("\"");
}
bool CJsonName::operator == (jstring str) const
{
  return name == str;
}

bool CJsonName::operator == (jstring const * const str) const
{
  return name == *str;
}

jstring CJsonName::GetNameString() const
{
  return name;
}

jchar const * const CJsonName::GetNameCString() const
{
  return name.c_str();
}

